const fs = require("fs");
const path = require("path");
const http = require("http");
let argv = process.argv[2];
const server = http.createServer((req, res) => {
    console.log(argv);
    if (argv) {
        let filePath = path.join(__dirname, argv);
        console.log(fs.existsSync(filePath));
        if (fs.existsSync(filePath)) {
            let fileContent = fs.readFileSync(filePath);
            res.end(fileContent);
        }
        else {
            console.log("该路径文件不存在");
        }
    }
    else {
        let filePath = path.join(__dirname, "fileReader1.js");
        let fileContent = fs.readFileSync(filePath);
        res.end(fileContent);

    }


})
server.listen(8081);
console.log("server is listening 8081")



